import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const originalPush = Router.prototype.push
// 重写了原型上的push方法，统一的处理了错误信息
Router.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}

export default new Router({
  routes: [
    {
      path: '/',
      name: 'Index-page',
      component: require('@/yicourse/Index').default,
      children: [
        {
          path: '/Home',
          name: 'Home-page',
          component: require('@/yicourse/home/HomePage').default
        },
        {
          path: '/myTrain',
          name: 'Train-page',
          component: require('@/yicourse/train/MyTrainPage').default
        },
        {
          path: '/record',
          name: 'Record-page',
          component: require('@/yicourse/record/RecordPage').default
        },
        {
          path: '/screen',
          name: 'Screen-page',
          component: require('@/yicourse/record/ScreenPage').default
        }
      ]
    },
    {
      path: '/recordWin',
      name: 'recordWin',
      component: require('@/yicourse/record/RecordWin').default,
      meta: {
        showTop: false
      }
    },
    {
      path: '*',
      redirect: '/'
    }
  ]
})
